{include file="public/head"}

<body>
<div id="wrapper">

    <div class="gray-bg dashbard-1">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                            <form class="form-horizontal m-t" enctype="multipart/form-data" id="uploadForm">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">导入Excel：</label>
                                    <div class="col-sm-8">
                                        <input id="user_excel" name="user_excel" type="file" class="form-control" required="" aria-required="true">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-3">
                                        <button class="btn btn-primary" type="submit" id="sub">确认导入</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>
{include file="public/footer"}
<script>
    $('#uploadForm').submit(function (e) {
        e.preventDefault();
        var formdata=new FormData();
        formdata.append('file',$('#user_excel')[0].files[0]);
        $.ajax({
            type:'post',
            dataType:'json',
            url:"{:url('User/ExcelImport')}",
            processData:false,  //告诉jQuery不要处理数据
            contentType: false,
            data:formdata,
            beforeSend: function() {
                layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            },
            success:function (data){
                layer.closeAll()
                if(data.status == 1){
                    layer.msg(data.message,{icon: 6,time:1500},function () {
                        window.top.location.reload();
                    });
                }else{
                    layer.msg(data.message,{icon: 5,time:1500});
                }
            },
            error: function (err) {
                layer.closeAll()
                console.log(err)
            }
        })
    });
</script>
</body>

</html>
